package com.bw1806.shop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.bw1806.pojo.TbContentCategory;
import com.bw1806.sellergoods.service.TbContentCategoryService;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @描述133333
 * @创建人 wangyue
 * @创建时间2020/11/1115:04
 */
@RestController //controller+responsebody
@RequestMapping("tbContentCategory")
public class TbContentCategoryController {

    @Reference
    private TbContentCategoryService tbContentCategoryService;

    @RequestMapping("list")
    public List<TbContentCategory> list(){
        return tbContentCategoryService.findAll();
    }

    /**
     * 分页模糊查询
     * @param tbTbContentCategory
     * @return
     */
    @RequestMapping("pagelist")
    public PageResult<TbContentCategory> pagelist(@RequestBody TbContentCategory tbTbContentCategory,int pageNum,int pageSize){
        return tbContentCategoryService.pagelist(tbTbContentCategory,pageNum, pageSize);
    }

    /**
     * 保存方法
     * @param tbTbContentCategory
     * @return
     */
    @RequestMapping("save")
    public Result save(@RequestBody TbContentCategory tbTbContentCategory){
        try {
            tbContentCategoryService.save(tbTbContentCategory);
            return new Result(true, "增加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "增加失败");
        }
    }
    /**
     * 根据id获取对象方法-回显
     * @return
     */
    @RequestMapping("getById")
    public TbContentCategory getById(Long id){
        return tbContentCategoryService.getById(id);
    }
    /**
     * 删除方法
     * @return
     */
    @RequestMapping("deletebth")
    public Result deletebth(Long[] ids){
        try {
            tbContentCategoryService.deletebth(ids);
            return new Result(true, "删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "删除失败");
        }
    }
}
